import { createRouter, createWebHistory } from 'vue-router';

const router = createRouter({
  history: createWebHistory('/'), // 将参数更改为你的基础URL的字符串值
  routes: [
    {
      path: '/',
      component: () => import('../views/Layout/index.vue'),
      // 首页属于Layout的二级路由
      children: [
        {
          path: '/',
          name: 'home',
          component: () => import('../views/Home/index.vue'),
        },
        {
          path: 'cloud',
          name: 'cloud',
          component: () => import('../views/Cloud/index.vue'),
        },
        {
          path: 'latency',
          name: 'latency',
          component: () => import('../views/Latency/index.vue'),
        },
        {
          path: 'international',
          name: 'international',
          component: () => import('../views/International/index.vue'),
        },
        {
          path: 'transfer',
          name: 'transfer',
          component: () => import('../views/Transfer/index.vue'),
        },
        {
          path: 'idc',
          name: 'idc',
          component: () => import('../views/IDC/index.vue'),
        },
        {
          path: 'sdwan',
          name: 'sdwan',
          component: () => import('../views/SDWan/index.vue'),
        },
        {
          path: 'about',
          name: 'about',
          component: () => import('../views/About/index.vue'),
        },
        {
          path: '/thanks',
          name: 'thanks',
          component: () => import('../views/Thanks/index.vue'),
        },
        {
          path: '/404',
          name: '404',
          component: () => import('../views/404/index.vue'),
        },
      ],
    },
    // {
    //   path: '/file',
    //   component: () => import('../views/File/index.vue'),
    // },
    // {
    //   path: '/test',
    //   component: () => import('../views/test/index.vue'),
    // },
    {
      path: '/:pathMatch(.*)*', // vue-router的新通配符
      redirect: '/404',
    },
  ],
  // 始终滚动到顶部
  scrollBehavior() {
    return {
      top: 0, // 切换路由时,始终返回顶部
      behavior: 'smooth', // 更丝滑的滚动行为
    };
  },
});

export default router;
